package com.dream21th.oauth.remote.fallback;

import com.dream21th.oauth.remote.AdminFeign;
import com.dream21th.common.ComResp;
import com.dream21th.common.dto.UserDTO;
import com.dream21th.common.dto.UserTokenDTO;
import com.dream21th.common.enums.RtnEnum;
import com.dream21th.common.exception.WebException;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class AdminFeignFallback implements FallbackFactory<AdminFeign> {

    @Override
    public AdminFeign create(Throwable throwable) {
        return new AdminFeign() {
            @Override
            public ComResp<UserDTO> info(String username) {
                throw new WebException(RtnEnum.WEB_ADMIN_ERROR);
            }

            @Override
            public ComResp<UserTokenDTO> queryUserLoginToken(String username) {
                throw new WebException(RtnEnum.WEB_ADMIN_ERROR);
            }

            @Override
            public ComResp saveUserLoginToken(UserTokenDTO userTokenDTO) {
                throw new WebException(RtnEnum.WEB_ADMIN_ERROR);
            }
        };
    }
}
